package com.malty.aiassistant.demo.invoke;

import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.ai.chat.messages.AbstractMessage;
import org.springframework.ai.chat.model.ChatModel;
import org.springframework.ai.chat.prompt.Prompt;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

/**
 * @author malty
 */
@Slf4j
@Component
public class SpringAiInvokeRunner implements ApplicationRunner {
    @Resource
    private ChatModel dashscopeChatModel;

    @Override
    public void run(ApplicationArguments args) {
        AbstractMessage chatResponse = dashscopeChatModel.call(new Prompt("你好 我是你的主人"))
                .getResult()
                .getOutput();
        System.out.println(chatResponse.getText());
    }
}
